package com.tianjian.common.logging;

import org.apache.log4j.Level;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.spi.LoggingEvent;

public class LoggingPatternLayout extends PatternLayout {

	@Override
	public String format(LoggingEvent event) {
		String message = (String) event.getMessage();
		if (event.getLevel().toInt() == Level.DEBUG.toInt()) {
			if ("java.sql.Connection".equals(event.getLoggerName()) || "java.sql.PreparedStatement".equals(event.getLoggerName())) {
				if (message.startsWith("ooo Using Connection [")) return null;
				if (message.startsWith("==>  Preparing: INSERT INTO T_SYSTEM_LOG (")) return null;
				if (message.matches("^==> Parameters: (/.*/.*/(.*)\\(String\\)), (\\[.*\\]com.*\\(String\\))[\\s\\S]*")) return null;
			}
		}
		return super.format(event);
	}

}
